import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'

const pathResolve = (dir) => {
  return resolve(process.cwd(), '.', dir)
}

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  server: {
    open: true,
    port: 3000 /* 设置端口 */,
    https: false,
    proxy: {
      '/api': {
        target: 'xxxx',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ''),
      },
    },
  },
  resolve: {
    alias: [
      // 文件系统路径的别名
      {
        find: /\/@\//,
        replacement: pathResolve('src') + '/',
      },
    ],
  },
})
